const obj1 = {
    name: "echo",
    foo: function (num1, num2) {
        console.log(this);
        console.log(this.name, num1 + num2);
    }
};
const obj2 = {
    name: "wer"
};
Function.prototype.HYBind = function (thisArg, ...args) {
    let fn = this;
    thisArg = (thisArg !== null && thisArg !== undefined) ? Object(thisArg) : window;
    return function (...arg) {
        thisArg.fn = fn;
        const result = thisArg.fn(...args, ...arg);
        delete thisArg.fn;
        return result;
    }
};
obj1.foo.bind(obj2)(1, 2);
obj1.foo.HYBind(obj2, 1)(2);